import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { qiankun } from 'vite-plugin-qiankun'

/**
 * Vite配置文件
 * @description Vue子应用的构建配置
 */
export default defineConfig({
  base: process.env.NODE_ENV === 'production' && window?.__POWERED_BY_QIANKUN__ ? '/vue-app/' : '/',
  plugins: [
    vue(),
    qiankun('vue-app', { useDevMode: true })
  ],
  server: {
    port: 3001,
    cors: true,
    headers: {
      'Access-Control-Allow-Origin': '*'
    }
  },
  build: {
    target: 'es2015',
    outDir: 'dist',
    rollupOptions: {
      output: {
        // 确保微应用可以独立运行
        format: 'system'
      }
    }
  }
}) 